package org.xshaokuang.loginandemail.tool;

import cn.nukkit.entity.Entity;
import cn.nukkit.inventory.InventoryHolder;
import cn.nukkit.item.Item;
import cn.nukkit.level.Location;
import cn.nukkit.math.Vector3;

public class Tool {
    public static boolean isOverTime(long timestamp) {
        return (System.currentTimeMillis() / 1000 - timestamp) > 0;
    }

    public static void addItem(Entity entity , Item item) {
        if(entity instanceof InventoryHolder && ((InventoryHolder) entity).getInventory().canAddItem(item)) {
            ((InventoryHolder) entity).getInventory().addItem(item);
        } else {
            dropItem(entity.getLocation(), item);
        }
    }

    public static void dropItem(Location location , Item item) {
        location.getLevel().dropItem(location, item, new Vector3(0, 1, 0));
    }


}
